package org.abratuhi.kvngroupware.model;

import org.jdom.Element;

public class User {

	String id = new String();
	String password = new String();
	
	String name = new String();
	String surname = new String();
	
	String teamId = new String();
	
	public User(){
		
	}
	public User(String id){
		setId(id);
	}
	public User(String id, String password, String team){
		setId(id);
		setPassword(password);
		setTeam(team);
	}
	public User(String id, String password, String name, String surname, String team){
		setId(id);
		setPassword(password);
		setTeam(team);
		setName(name);
		setSurname(surname);
	}
	
	public String getId(){
		return this.id;
	}
	public String getPassword(){
		return this.password;
	}
	public String getName(){
		return this.name;
	}
	public String getSurname(){
		return this.surname;
	}
	public String getTeamId(){
		return this.teamId;
	}
	
	
	public void assignTempId(String id){
		setId(id);
	}
	void setId(String id){
		this.id = id;
	}
	void setPassword(String password){
		this.password = password;
	}
	void setName(String name){
		this.name = name;
	}
	void setSurname(String surname){
		this.surname = surname;
	}
	void setTeam(String team){
		this.teamId = team;
	}
	
	public Element toElement(){
		Element user = new Element("user");
		user.setAttribute("id", getId());
		user.setAttribute("password", getPassword());
		user.setAttribute("name", getName());
		user.setAttribute("surname", getSurname());
		user.setAttribute("teamId", getTeamId());
		return user;
	}
	public static User fromElement(Element eUser){
		User user = new User();
		user.setId(eUser.getAttributeValue("id"));
		user.setPassword(eUser.getAttributeValue("password"));
		user.setName(eUser.getAttributeValue("name"));
		user.setSurname(eUser.getAttributeValue("surname"));
		user.setTeam(eUser.getAttributeValue("teamId"));
		return user;
	}

}
